using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Media.Imaging;
using ClientCommonWpf;
using Director.Properties;

namespace Director
{
	public class OutputItem
	{
		static readonly Dictionary<EOutputItemType, BitmapSource> _sources = new Dictionary<EOutputItemType, BitmapSource>();

		static OutputItem()
		{
			foreach (EOutputItemType value in Enum.GetValues(typeof(EOutputItemType)))
			{
				_sources.Add(value, GetBitmap(value).Source());
			}
		}

		private static Bitmap GetBitmap(EOutputItemType value)
		{
			switch (value)
			{
				case EOutputItemType.ServiceLog:
					return Resources.server_warning;
				case EOutputItemType.ServiceError:
					return Resources.server_error;
				case EOutputItemType.Debug:
					return Resources.debug;
				case EOutputItemType.Log:
					return Resources.message;
				case EOutputItemType.Error:
					return Resources.error;
				default:
					throw new ArgumentOutOfRangeException("value");
			}
		}

		public OutputItem(EOutputItemType type, string message)
		{
			Image = _sources[type];
			Message = message;
			ItemType = type;
			Time = DateTime.Now;
		}

		public BitmapSource Image { get; private set; }

		public string Message { get; set; }

		public EOutputItemType ItemType { get; private set; }

		public DateTime Time { get; private set; }
	}

	public enum EOutputItemType
	{
		ServiceLog,
		ServiceError,
		Debug,
		Log,
		Error,
	}
}